package com.dd;

import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.ArrayList;

import com.chantel.tool.db.DBUtil;

public class XiangMuShiYeBuManager {
	
	public static boolean InsertNewXiangMuShiYeBu(String strMingCheng)
	{
		DBUtil du = DBUtil.getInstance();
		Map m = new HashMap();
		m.put("MingCheng", strMingCheng);
		
		boolean bool_res = du.insertRecord("XiangMuShiYeTable", m);
		return bool_res;
	}
	
	public static ArrayList GetAllXiangMuShiYeBuInfos()
	{
		DBUtil du = DBUtil.getInstance();
		
		ArrayList aL = new ArrayList();
		String sql = "select* from XiangMuShiYeTable";
		List l = du.getRecords(sql);
		
		Iterator it =  l.iterator();
		while(it.hasNext())
		{
			Map m = (Map)it.next();
			
			int id = ((Integer) m.get("XiangMuShiYeBuID")).intValue();			
			String mingCheng = (String)m.get("MingCheng");	
			
			System.out.println(id);
			System.out.println(mingCheng);
			XiangMuShiYeBu xm = new XiangMuShiYeBu(id,mingCheng);			
			aL.add(xm);	
		}
		
		return aL;
	}
	public static Map GetAllXiangMuShiYeBuInfosMap()
	{
		DBUtil du = DBUtil.getInstance();
		
		Map mIdToMingCheng= new HashMap();
		
		String sql = "select* from XiangMuShiYeTable";
		
		List l = du.getRecords(sql);
		Iterator itr = l.iterator();
		while (itr.hasNext()) {
			Map m1 = (Map) itr.next();
			
			String id =  Integer.toString(((Integer) m1.get("XiangMuShiYeBuID")).intValue());
			String MengCheng = (String)m1.get("MingCheng");
			
			mIdToMingCheng.put(id, MengCheng);
		}
		
		
		return mIdToMingCheng;
	}
	
}
	